<?php
/*
 BMForum Datium! Bulletin Board Systems
 Version : Datium!
 
 This is a freeware, but don't change the copyright information.
 A SourceForge Project.
 Web Site: http://www.bmforum.com
 Copyright (C) Bluview Technology
*/
include_once("datafile/config.php");
include_once("include/template.php");
include_once("getskin.php");
$cip = $ip;
include_once("lang/$language/index.php");

$lang_zone = array("onlyread"=>$onlyread, "newpost"=>$newpost, "nonewpost"=>$nonewpost, "todaybd"=>$todaybd, "poteo"=>$poteo, "forum_line"=>$forum_line, "bm_skin"=>$bm_skin, "otherimages"=>$otherimages, "whosonlinelang"=>$whosonlinelang, "popp"=> $popp, "indexinfo" => $indexinfo);
$template_name = newtemplate("index", $temfilename, $styleidcode, $lang_zone);
    
$acount = count($usergroupdata);
$onlinests = $shareforum_js =  "";
for ($i = 0; $i < $ugsocount; $i++) {
    $getit = $ugshoworder[$i];
    $onlinetushi = explode("|", $usergroupdata[$getit]);
    if ($unshowit[$getit] != "1") {
        $onlinests .= "<img src='$otherimages/system/{$onlinetushi[1]}' alt='' /> {$onlinetushi[0]}&nbsp;";
    } 
} 
if ($allow_ajax_browse && $ajax_online) {
    whosonline();
    require($template_name);
	exit;
}

$query = "SELECT * FROM {$database_up}lastest WHERE pageid='index'";
$result = bmbdb_query($query);
$thelastest = bmbdb_fetch_array($result);

$lasttodaytime = gmdate("zY", $thelastest['lasttodaytime'] + $bbsdetime * 3600);
$lasttodaytime_a = gmdate("zY", $timestamp + $bbsdetime * 3600);
if ($lasttodaytime != $lasttodaytime_a) {
    $thelastest['ydaynew'] = $thelastest['todaynew'];
    $thelastest['todaynew'] = 0;
    $nquery = "UPDATE {$database_up}lastest SET lasttodaytime='$timestamp',ydaynew='{$thelastest['ydaynew']}',todaynew=0 WHERE pageid='index'";
    $result = bmbdb_query($nquery);
} 

$infotwotwo = " <span class=\"jiazhongcolor\"><a href=\"profile.php?job=show&amp;target=" . urlencode($thelastest['lastreged']) . "\">{$thelastest['lastreged']}</a></span> ";


$posttilebac = $thelastest['lastposts'];
$thelastest['lastposts'] = $thelastest['lastposts'];
if (utf8_strlen($thelastest['lastposts']) >= 6) $thelastest['lastposts'] = substrfor($thelastest['lastposts'], 0, 6) . "...";
require("header.php");

if ($bbs_news) {
    if (file_exists('datafile/announcement.php')) {
        $announcementmtime = filemtime('datafile/announcement.php');
        $announcementmtime = get_date($announcementmtime) . " " . get_time($announcementmtime);
        include('datafile/announcement.php');
    } 
    if ($announcement) {
        $announcementtext = str_replace("\n", " ", $announcement);
        $announcement = "{$announcementtext}&nbsp;&nbsp;({$announcementmtime})&nbsp;&nbsp;&nbsp;&nbsp;";
    } else {
    	$announcement = "";
    }
    
    if (file_exists("datafile/announcesys.php")) {
        $announcelist = file("datafile/announcesys.php");
    } 

    $count = count($announcelist);
    if ($count == 0 && !$announcementtext) {
        $bbs_news = 0;
    }
    for ($i = 0;$i < $count;$i++) {
        $ic = $i + 1;
        list($aauthor, $atitle, $atime, $acontent, $amember) = explode("|", $announcelist[$i]);
        $almdtime = get_date($atime) . ' ' . get_time($atime);
        $size_gg = utf8_strlen($acontent);
        $ag = $timestamp - $atime;
        $announcement .= "<span class='jiazhongcolor'><strong><a href='announcesys.php?job=read&amp;msg=$i' target='_blank'>$atitle</a></strong>&nbsp;&nbsp;($almdtime)&nbsp;&nbsp;&nbsp;&nbsp;";
    } 
} 

if ($login_status == 1) {
	$level = getUserLevel($postamount, $userbym, $username, $logonutnum);
} else {
    if ($log_va && $fastlogin) {
        $authnum = $gd_auth ? getCode(4,1) : rand(10000, 99999);
        $_SESSION[checkauthnum] = $authnum;
    }
} 

$des = $stextnow = $simgnow = "";
$navimode = newmode;
$snavi_bar[0] = $programname;
if ($cateid) $des = "<a href='forums.php?trash=trash&cateid=$cateid'>$fenleiq[2]</a> | ".get_categroy_admin($cateid, $sxfourmrow, $forumscount);
navi_bar($des);

if ($see_a_tags && $bmfopt["hot_tags"])
{
	$hot_tags_list = "";
    $result = bmbdb_query("SELECT * FROM {$database_up}tags ORDER BY 'threads' DESC LIMIT 0,30"); // max tags number: 30

    while (false !== ($row = bmbdb_fetch_array($result))) {
        $title_tagname = $row['tagname']." ({$row['threads']})";
        $size_t = rand(12,14);
        $hot_tags_list .= "<a title='$title_tagname' style='text-decoration:underline;font-size:" . $size_t . "px' href='plugins.php?p=tags&amp;forumid=$forumid&amp;tagname=" . urlencode($row['tagname']) . "'>{$row['tagname']}</a>&nbsp;&nbsp;\n";
    } 
}

$count = count($forumlist);
for ($i = 0; $i < $count; $i++) {
    $detail = explode('|', $forumlist[$i]);
} 

$line = $sxfourmrow;
$xxxcount = $forumscount;
for($i = 0;$i < $xxxcount;$i++) {
	if ($bmfopt['hidebyug'] && !check_forum_permission(0, 1, $line[$i])) {
		continue;
	}
    if ($line[$i]['type'] == 'forum' || $line[$i]['type'] == 'jump' || $line[$i]['type'] == 'selection' || $line[$i]['type'] == 'former' || $line[$i]['type'] == 'locked' || $line[$i]['type'] == 'closed') {
    	if ($cateid) {
    		if ($this_cat == 1) {
    			forum_line($line[$i]['type'], $line[$i], $line);
    		}
    		continue;
    	} else {
	        if ($tnewrow) forum_line_row($line[$i]['type'], $line[$i], $line);
	        else forum_line($line[$i]['type'], $line[$i], $line);
	    }
    } elseif ($line[$i]['type'] == 'category') {
    	if ($cateid) {
    		if ($this_cat == 1) break;
    		if ($line[$i]['id'] == $cateid) {
    			category_line($line[$i]['bbsname'], $line[$i]['id'], $line[$i], $line[$i]['caterows']);
    			$this_cat = 1;
    			$bmforumlist[0]['TROW']="";
    		}
    	} else category_line($line[$i]['bbsname'], $line[$i]['id'], $line[$i], $line[$i]['caterows']);
    } 
    if (check_permission($username, $line[$i]['type']) && ($line[$i]['type'] == 'hidden' || $line[$i]['type'] == 'forumhid')) {
    	if ($cateid) {
    		if ($this_cat == 1) {
    			forum_line($line[$i]['type'], $line[$i], $line);
    		}
    		continue;
    	} else {
	        if ($tnewrow) forum_line_row($line[$i]['type'], $line[$i], $line);
	        else forum_line($line[$i]['type'], $line[$i], $line);
	    }
    } 
} 


// --Allied Forums------
if ($usemarquee[0]) $stextnow = "<marquee scrollamount='1' TrueSpeed scrolldelay='30' onmouseover='this.stop();' onmouseout='this.start();'>";
if ($usemarquee[1]) $simgnow = "<marquee scrollamount='1' TrueSpeed scrolldelay='30' onmouseover='this.stop();' onmouseout='this.start();'>";


if ($cachejs == 1) {
    $shareforum_js = "<script src='datafile/cache/sharepic.js' type='text/javascript'></script>\n<script src='datafile/cache/sharetext.js' type='text/javascript'></script>";
    $simgnow .= "<div id='simgnow'></div>";
    $stextnow .= "<div id='stextnow'></div>";
} else {
    $query = "SELECT * FROM {$database_up}shareforum ORDER BY 'showorder' ASC";
    $result = bmbdb_query($query);
    $count = bmbdb_num_rows($result);
    while (false !== ($line = bmbdb_fetch_array($result))) {
        $alliedforuminfo = str_replace("\n", "", $line['des']);
        $alliedforumtype = str_replace("\n", "", $line['type']);
        if ($alliedforumtype == "pic") {
            $simgnow .= " <a href='{$line['url']}' target='_blank'><img width='88' height='31' alt='{$line['name']}\n$alliedforuminfo' src='{$line['gif']}' border='0' /></a>&nbsp;            ";
            $simgnow .= " ";
        } else {
            $stextnow .= " <a title='{$line['name']}\n$alliedforuminfo' href='{$line['url']}' target='_blank'>{$line['name']}</a>&nbsp;             ";
            $stextnow .= " ";
        } 
    } 
} 

if ($usemarquee[0]) $stextnow .= "</marquee>";
if ($usemarquee[1]) $simgnow .= "</marquee>";
    
$sharenum = $sharenum + $count;

if ($todayb_show) {
	$counowtd = 0;
    $thisyear = getdate($timestamp);
    $thisday = $thisyear["mday"];
    $thismonth = $thisyear["mon"];
    $thisyear = $thisyear["year"];
    $bdfile = "datafile/birthday/{$thismonth}_$thisday";
    $bddata = @file($bdfile);
    $bdccount = count($bddata);
    for($bdc = 0;$bdc < $bdccount;$bdc++) {
		$detail = explode("|", $bddata[$bdc]);
    	if ($detail[0]) {
	    	$cluage = "";
			if ($detail[2] != 0) $cluage = "(". ($thisyear - $detail[2]) ." $todaybd[3])";
			$tdbdshow .= "<a href='profile.php?job=show&amp;target=" . urlencode($detail[0]) . "'>$detail[0]</a> $cluage &nbsp;";
			$counowtd++;
		}
    } 
    if ($counowtd == 0) $tdbdshow = $todaybd[4];

} 
whosonline();

require($template_name);
require("footer.php");
exit;
// 分类显示模块
function category_line($name, $categoryid, $line, $trow)
{
    global $echoedcate, $current_width, $current_rows, $current_cid, $bmforumlist, $outpused, $tnewrow, $leiji, $catea, $cateb, $preoutput_row, $catec, $cated, $replaces_a, $replaces_b, $replaces_c, $replaces_d, $outputed, $temfilename, $fenleiq, $i, $otherimages, $forum_cidi;
    
    $current_rows = $current_width = $echoedcate = 0;

    $tnewrow = $trow;

    if (empty($line['adminlist'])) {
        $clist = "<select><option target=_self value=\"#\">$fenleiq[0]</option><option target=_self value=\"#\">---------</option><option target=_self value=\"#\">$fenleiq[1]</option></select>";
    } else {
        $admin_c_list = explode("|", $line['adminlist']);
        $countc = count($admin_c_list)-1;
        $clist = "<select onchange='adminjump(this)'><option>$fenleiq[0]</option><option>---------</option>";
        for ($ia = 0; $ia < $countc; $ia++) {
            if (!empty($admin_c_list[$ia])) {
                $clist .= "<option value=\"profile.php?job=show&amp;target=" . urlencode($admin_c_list[$ia]) . "\">$admin_c_list[$ia]</option>";
            } 
        } 
        $clist .= "</select> ";
    } 
    
    $current_cid = $categoryid;
    $forums_stat[$current_cid] = 0;
    
    
    if ($line['caterows']) {
	    $current_rows = $line['caterows'];
	    $current_width= floor(100/$line['caterows']);
	}
    
   	$bmforumlist[] = array("current_rows"=>$current_rows,"TROW" => $trow, "TYPE"=> "category", "ID" => $categoryid,"NAME"=>$name, "CLIST"=>$clist);

} 
// 版块横列
function forum_line_row($forum_type, $line, $allline)
{
    global $detail, $current_rows, $current_width, $forums_stat, $current_cid, $bmforumlist, $bmfopt, $echoedcate, $outpused, $forum_line, $bbsdetime, $popp, $replaces_a, $replaces_c, $th_arr, $replaces_b, $replaces_d, $leiji, $preoutput_row, $xxxcount, $forumlist, $preoutput, $po, $temfilename, $all_count, $all_lastmo, $time_2, $time_1, $script_pos, $forum_admin, $login_status, $idpath, $newpost, $onlyread, $nonewpost, $posticon, $pollicon, $ucomicon, $otherimages, $timestamp, $minoffset;

    $ztnum = 0;
    $ztnum1 = 0;
    

    $ztnum = $line['topicnum'];
    $ztnum1 = $line['replysnum'];
    $ztnum2 = $line['todayp'];

    $lasttodaytime = gmdate("zY", $line['todaypt'] + $bbsdetime * 60 * 60);
    $lasttodaytime_a = gmdate("zY", $timestamp + $bbsdetime * 60 * 60);
    
    if ($lasttodaytime != $lasttodaytime_a) {
    	$ztnum2 = 0;
    }
    
    for($ax = 0;$ax < $xxxcount;$ax++) {
        if ($allline[$ax]['blad'] == $line['id']) {
            $ztnum += $allline[$ax]['topicnum'];
            $ztnum1 += $allline[$ax]['replysnum'];
            $lasttodaytime = gmdate("zY", $allline[$ax]['todaypt'] + $bbsdetime * 60 * 60);
            
            if ($lasttodaytime == $lasttodaytime_a) {
                $ztnum2 += $allline[$ax]['todayp'];
            }
        } 
    } 

    $forumlabel = "<span class='forumnamelink'><a title=\"{$line['cdes']}\" onfocus='this.blur();'  href=\"".($bmfopt['rewrite'] ? "forums_{$line['id']}" :"forums.php?forumid={$line['id']}")."\">{$line['bbsname']}</a></span>";

    if (!empty($line['adminlist'])) {
        $forum_admin = explode("|", $line['adminlist']);
        $count = count($forum_admin)-1;
        for ($j = 0; $j < $count; $j++) {
            $adminname = $forum_admin[$j];
            $admin_list_row .= " <a title=\"$forum_line[12] $adminname $forum_line[13]\" href=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</a> ";
        } 
    } 
    
    if ($line['forum_icon']) $line['forum_icon'] = "<img src='{$line['forum_icon']}' alt='' />";

    $ztnum = "$popp[15] $ztnum / $popp[16] $ztnum1 / $popp[23] $ztnum2";
    
    $forums_stat[$current_cid]++;
    
   	$bmforumlist[] = array("current_width"=>$current_width,"current_rows"=>$current_rows,"ROWF"=>1,"admin_list_row" => $popp[14]." ".$admin_list_row, "ztnum" => $ztnum, "forum_icon" => $line['forum_icon'], "forumdes" => $line['cdes'], "forumlabel" => $forumlabel, "TYPE"=> "forum", "ID" => $line['id']);


} 
// 版块显示模块
function forum_line($forum_type, $line, $allline)
{
    global $detail, $current_cid, $forums_stat, $bmforumlist, $bmfopt, $enter_tb, $bbsdetime, $echoedcate, $outpused, $listmmlist, $fenleiq, $forum_line, $xxxcount, $forumlist, $preoutput, $po, $temfilename, $all_count, $all_lastmo, $time_2, $time_1, $script_pos, $forum_admin, $login_status, $idpath, $newpost, $onlyread, $nonewpost, $posticon, $pollicon, $ucomicon, $otherimages, $timestamp, $minoffset;

    $aviewpost = $line['naviewpost'];
    if ($aviewpost == "openit") {
        $filetopn = "article.php";
    } else {
        $filetopn = "topic.php";
    } 

    if ($echoedcate == 0) {
        echo $outpused;
        $echoedcate = 1;
    }

    $ztnum = $line['topicnum'];
    $ztnum1 = $line['replysnum'];
    $ztnum2 = $line['todayp'];
    $lasttodaytime = gmdate("zY", $line['todaypt'] + $bbsdetime * 60 * 60);
    $lasttodaytime_a = gmdate("zY", $timestamp + $bbsdetime * 60 * 60);
    
    if ($lasttodaytime != $lasttodaytime_a) {
    	$ztnum2 = 0;
    }


    for($ax = 0;$ax < $xxxcount;$ax++) {
        if ($allline[$ax]['blad'] == $line['id'] && check_permission($username, $allline[$ax]['type']) ) {
        	$orgtitle = $allline[$ax]['fltitle'] = stripslashes($allline[$ax]['fltitle']);
            if (utf8_strlen($allline[$ax]['fltitle']) >= 12) $allline[$ax]['fltitle'] = substrfor($allline[$ax]['fltitle'], 0, 12) . "..";
            $modifytime = $allline[$ax]['flposttime'];
            $allline[$ax]['flposttime'] = getfulldate($modifytime);
            $allline[$ax]['fltitle'] = htmlspecialchars($allline[$ax]['fltitle']);
            if ($time_2) {
                $timetmp_a = $timestamp - $modifytime;
                $timetoshow = get_add_date($timetmp_a);
                if ($timetoshow == "getfulldate") {
                    $timetoshow = $allline[$ax]['flposttime'];
                } 
            } else {
                $timetoshow = $allline[$ax]['flposttime'];
            } 
            $titlea[] = "<a title=\"{$orgtitle} - {$allline[$ax]['flposter']}\" href=\"".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$allline[$ax]['flfname']}_last#postend" : "$filetopn?getlastpost=yes&amp;forumid={$allline[$ax]['id']}&amp;ct={$allline[$ax]['flfname']}&amp;page=last#postend")."\">{$allline[$ax]['fltitle']}</a>";
            $usera[] = "<a href=\"profile.php?job=show&amp;target=" . urlencode($allline[$ax]['flposter']) . "\">{$allline[$ax]['flposter']}</a> <a href='".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$allline[$ax]['flfname']}" : "$filetopn?getlastpost=yes&amp;ct={$allline[$ax]['flfname']}&amp;forumid={$allline[$ax]['id']}")."' title='$forum_line[3]'><img border='0' src='$otherimages/system/lastpost.gif' alt='' /></a>";
            $timea[] = $timetoshow;
            $timesa[] = $modifytime;
            
            $lasttodaytime = gmdate("zY", $allline[$ax]['todaypt'] + $bbsdetime * 60 * 60);
            
            if ($lasttodaytime == $lasttodaytime_a) {
                $ztnum2 += $allline[$ax]['todayp'];
            }
            
            if ($bmfopt['showsubforum'] && !($bmfopt['hidebyug'] && !check_forum_permission(0, 1, $allline[$ax]))) {
	            $showsubforum[] = "<a href=\"".($bmfopt['rewrite'] ? "forums_{$allline[$ax]['id']}" : "forums.php?forumid={$allline[$ax]['id']}")."\">{$allline[$ax]['bbsname']}</a>";
	        }
            
            $ztnum += $allline[$ax]['topicnum'];
            $ztnum1 += $allline[$ax]['replysnum'];
        } 
    } 

    $orgtitle = $line['fltitle'] = stripslashes($line['fltitle']);
    if (utf8_strlen($line['fltitle']) >= 12) $line['fltitle'] = substrfor($line['fltitle'], 0, 12) . "..";
    $modifytime = $line['flposttime'];
    $line['flposttime'] = getfulldate($modifytime);
    $line['fltitle'] = htmlspecialchars($line['fltitle']);
    if ($time_2) {
        $timetmp_a = $timestamp - $modifytime;
        $timetoshow = get_add_date($timetmp_a);
        if ($timetoshow == "getfulldate") {
            $timetoshow = $line['flposttime'];
        } 
    } else {
        $timetoshow = $line['flposttime'];
    } 

    $titlea[] = "<a title=\"{$orgtitle} - {$line['flposter']}\" href=\"".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$line['flfname']}_last#postend" : "$filetopn?getlastpost=yes&amp;ct={$line['flfname']}&amp;forumid={$line['id']}&amp;page=last#postend")."\">{$line['fltitle']}</a>";
    $usera[] = "<a href=\"profile.php?job=show&amp;target=" . urlencode($line['flposter']) . "\">{$line['flposter']}</a> <a href='".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$line['flfname']}" : "$filetopn?getlastpost=yes&amp;ct={$line['flfname']}&amp;forumid={$line['id']}")."' title='$forum_line[3]'><img border='0' src='$otherimages/system/lastpost.gif' alt='' /></a>";
    $timea[] = $timetoshow;
    $timesa[] = $modifytime;

    $countarray = count($timesa);
    for($cai = 0;$cai < $countarray;$cai++) {
        if ($timesa[$cai] > $times) {
            $title = $titlea[$cai];
            $user = $usera[$cai];
            $time = $timea[$cai];
            $times = $timesa[$cai];
        } 
    } 
    if ($forum_type == "forum" || $forum_type == "former" || $forum_type == "forumhid") {
        $last_modify_list_time_check = get_date($times);
        $last_modify_list_time_check = explode("-", $last_modify_list_time_check);
        $nowdatetime = get_date($timestamp);
        $nowdatetime_check = explode("-", $nowdatetime); 
        // ----- is there any new post? ------
        // echo $lastvisit;echo $lastvisit-$modifytime;
        if ($nowdatetime_check[1] == $last_modify_list_time_check[1] && $nowdatetime_check[2] == $last_modify_list_time_check[2] && $nowdatetime_check[0] == $last_modify_list_time_check[0]) $forum_icon = '<img src="' . $newpost . '" border="0" alt="" />';
        else $forum_icon = '<img src="' . $nonewpost . '" border="0" alt="" />';
    } else {
        $forum_icon = '<img src="' . $onlyread . '" border="0" alt="" />';
    } 
    $forumlabel = "<span class='forumnamelink'><a onfocus='this.blur();' href=\"".($bmfopt['rewrite'] ? "forums_{$line['id']}" : "forums.php?forumid={$line['id']}")."\">{$line['bbsname']}</a></span>";

    if ($line['type'] == 'locked' && !$enter_tb) {
        $title = "";
    } 

    if ($listmmlist == 1) $admin_list = "<select onchange='javascript:window.location=this.value' style='width: 100px'>";
    if (!empty($line['adminlist'])) {
        $forum_admin = explode("|", $line['adminlist']);
        $count = count($forum_admin)-1;
        for ($j = 0; $j < $count; $j++) {
            $adminname = $forum_admin[$j];
            if ($listmmlist == 1) {
                $hasadmin = 1;
                if ($adminname != "") $admin_list .= "<option value=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</option>";
            } else $admin_list .= "<a title=\"$forum_line[12] $adminname $forum_line[13]\" href=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</a>";
            if ($j != $count-1) $admin_list .= ",";
            $admin_list_row .= " <a title=\"$forum_line[12] $adminname $forum_line[13]\" href=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</a> ";
        } 
    } 
    if ($hasadmin != 1 && $listmmlist == 1) $admin_list .= "<option>$fenleiq[1]</option>";
    if ($listmmlist == 1) $admin_list .= "</select>";
    if ($line['forum_icon'] <> "") $line['forum_icon'] = "<img src='{$line['forum_icon']}' alt='' />";
    
    if ($bmfopt['showsubforum'] && $showsubforum) {
    	$statforum = count($showsubforum) - 1;
    	$tsubforum = "<br />$forum_line[20]";
        for ($i = 0; $i <= $statforum; $i++) {
            $tsubforum .= $showsubforum[$i];
            if ($i != $statforum) $tsubforum .= ", ";
        }
    }
    
    $forums_stat[$current_cid]++;
    
    $bmforumlist[] = array("teamicon"=> $line['forum_icon'], "filetopn" => $filetopn, "subforums" => $tsubforum, "user" => $user, "admin_list" => $admin_list, "admin_list_row" => $admin_list_row, "time" => $time, "title" => $title, "ztnum2" => $ztnum2, "ztnum1" => $ztnum1, "ztnum" => $ztnum, "forum_des" => $line['cdes'], "forum_icon" => $forum_icon,"forumlabel" => $forumlabel, "TYPE"=> "forum", "ID" => $line['id'],"NAME"=>$line['bbsname'], "CLIST"=>$clist);

} 
// UNIX 时间转换
function get_stamp($last_str)
{
    list($last_date, $last_time) = explode(" ", $last_str);
    list($y, $m, $d) = explode("-", $last_date);
    list($h, $minute) = explode(":", $last_time);
    return mktime($h, $minute, 0, $m, $d, $y);
} 
// 谁与我同在
function whosonline()
{
    global $timestamp, $unshowit, $online_show_anti, $show2s, $see_amuser, $shows, $whosonlinelang, $online_show, $view_index_online, $usergroupdata, $online_limit, $admin_name, $admin_list, $otherimages, $usertype, $username, $id_unique;
    $onlinefile = "datafile/online.php";
    $guestfile = file("datafile/guest.php");
    $guestno = count($guestfile);
    $useryno = 0;
    $userno = 0;
    $online_user = file($onlinefile);
    if (file_exists('datafile/zy.php')) $zyinfo = explode('|', readfromfile('datafile/zy.php'));
	$userno = $count = count($online_user);
	
    $userlist = "<table width='100%'><tr>";
    $idd = 1;
    
    if ($unshowit[6] != 1) {
    	$online_user = array_merge((array)$online_user,(array)$guestfile);
    	$count+=count($guestfile);
    }

    if (($online_show == "" && $view_index_online == "1") || $online_show == show) {
    	
        $userno = "";
        for ($i = 0; $i < $count; $i++) {
            $addproinfo = "";
            $online_user_info = explode("|", $online_user[$i]);
            if ($online_user_info[1] != "") {
            	
                if ($online_user_info[11] == "yes") $useryno++;
                if ($timestamp - $online_user_info[2] <= $online_limit && ($online_user_info[11] != "yes" || ($online_user_info[11] == "yes" && $see_amuser == 1))) {
                    if ($online_user_info[11] == "yes") $addproinfo = " ($whosonlinelang[1])";
                    $br = "";
                    if (floor($idd / 7) * 7 == $idd) {
                        $br = "</tr><tr>";
                    } 
                    $idd++;
	            	if ($unshowit[6] != 1 && ($now_guest == 1 || trim($online_user_info[10]) == "")) {
	            		if ($now_guest != 1) {
	                    	$usertype = explode("|", $usergroupdata[6]);
	            			$now_guest = 1;
	            		}
	            		$userlist .= "<td width='12%'><img border='0' src='$otherimages/system/{$usertype[1]}' /> $online_user_info[1]&nbsp;</td>$br";
	            	} else {
	                    $usertype = explode("|", $usergroupdata[$online_user_info[10]]);
                    	
                    	$userlist .= "<td width='12%'><a href=\"messenger.php?job=write&amp;target=" . urlencode($online_user_info[1]) . "\"><img alt=\"$whosonlinelang[2]{$usertype[0]}{$whosonlinelang[3]}\" border='0' src='$otherimages/system/{$usertype[1]}' /></a> <a title=\"$whosonlinelang[4]{$usertype[0]}$whosonlinelang[5] $addproinfo\" href='profile.php?job=show&amp;target=" . urlencode($online_user_info[1]) . "'>$online_user_info[1]</a>&nbsp;</td>$br";
                    }
                } 
                if ($now_guest != 1 && $online_user_info[11] != "yes") $userno++;
            } 
        } 
    } 
    if ($online_show == show) {
        $shows .= "<tr><td class='forumcolorone_align'>" .$userlist. "</table></td></tr>";
    } elseif ($online_show == "") {
        if ($view_index_online == "1") {
            $shows .= "<tr><td class='forumcolorone_align'>" .$userlist. "</table></td></tr>";
        } 
    }
    $usernoa = $userno + $guestno + $useryno;
    if ($zyinfo[0] <= $usernoa) {
        writetofile('datafile/zy.php', $usernoa . "|" . $timestamp);
        $zyinfo = explode('|', readfromfile('datafile/zy.php'));
    } 
    if (($online_show == "" && $view_index_online == "1") || $online_show == "show") {
    	$online_show_anti = "hide";
    } else {
    	$online_show_anti = "show";
    }
    $zy_info = getfulldate($zyinfo[1]);
    $usernob = $userno + $useryno;
    $show2s .= "$whosonlinelang[6] <strong>$usernob</strong> $whosonlinelang[7] (<strong>$useryno</strong> $whosonlinelang[8]) $whosonlinelang[10] <strong>$guestno</strong> $whosonlinelang[11]<strong>$usernoa</strong>$whosonlinelang[12] | $whosonlinelang[13] <strong>$zyinfo[0]</strong> $whosonlinelang[14] $zy_info";
} 
function get_categroy_admin($cateid, $sxfourmrow, $forumscount)
{
	global $fenleiq;
	$line = $sxfourmrow;
	$xxxcount = $forumscount;
	for($i = 0;$i < $xxxcount;$i++) {
	    if ($line[$i]['id'] == $cateid) {
	        $cate_name = $line[$i]['bbsname'];
	        $admin_c_list = explode("|", $line[$i]['adminlist']);
	        if (empty($admin_c_list[0])) {
	            $clist = "<select><option value=\"#\">$fenleiq[0]</option><option value=\"#\">---------</option><option  value=\"#\">$fenleiq[1]</option></select>";
	        } else {
	            $countc = count($admin_c_list);
	            $clist = "<select onchange='adminjump(this)'><option>$fenleiq[0]</option><option>---------</option>";
	            for ($ia = 0; $ia < $countc; $ia++) {
	                if (!empty($admin_c_list[$ia])) {
	                    $clist .= "<option value=\"profile.php?job=show&amp;target=" . urlencode($admin_c_list[$ia]) . "\">$admin_c_list[$ia]</option>";
	                } 
	            } 
	            $clist .= "</select> ";
	        } 
	    }
	}	
	return $clist;
}